/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: xiaotutu
 * Date: 2023-10-27
 * Time: 14:09
 */

class Student {
    private String name;

    private int age;

    public static String classRoom;

    public Student() {
        System.out.println("不带参数的构造方法!");
    }

    // 实例(构造)代码块
    {
        this.name = "zhang san";
        this.age = 18;

    }

    // 静态代码块
    static {
        classRoom = "301";
    }

    public void show() {
        System.out.println(this.name + " 年龄是: "+ this.age+ " 他正在上课!");
    }

}

public class Test {
    public static void main(String[] args) {
        Student student = new Student();
        student.show();
        System.out.println("他所在的班级是:" + Student.classRoom);
    }
}


